#include "stm32f10x.h"                  // Device header
#include "Delay.h"
#include "OLED.h"
#include "Serial.h"
#include "Ds18b20.h"
#include "Buzzer.h"
#include "PWM.h"

uint8_t ucbuf[17];
float temp_data=0.0;
float temp_data1=0.0;


void TEMP_Value_Conversion()
{
	temp_data=DS18B20_Get_Temp();
	temp_data1=temp_data/10.0;
	
	sprintf((char*)ucbuf,"%4.2f",temp_data1);
	OLED_ShowString(1,1,"Temp:");
  OLED_ShowString(1,6,(uint8_t*)ucbuf);
	OLED_ShowChar(1,11,'C');
}


int main(void)
{
	uint8_t   i=0;
	uint16_t  dis=0;
	
	OLED_Init();
	DS18B20_Init();
	Serial_Init();
	Buzzer_Init();
  PWM_Init();
	while(1)
	{	
		TEMP_Value_Conversion();
		
		if(temp_data1 >= 27.0)
		{
			Buzzer_ON();
		makerobo_led_ColorSet(0xff,0x00); 
		Delay_ms(500);
		makerobo_led_ColorSet(0x00,0xff); 
		Delay_ms(500);
		makerobo_led_ColorSet(0xff,0x45);
		Delay_ms(500);
		makerobo_led_ColorSet(0xff,0xff);
		Delay_ms(500);
		makerobo_led_ColorSet(0x7c,0xfc);
		Delay_ms(500);
		}
		else
		{
			Buzzer_OFF();
		}
		Delay_ms(500); 
	}
}

